package com.keke.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Arrays;

/**
 * @ClassName: HelloController
 * @Description:
 * @Author: zhangjin
 * @Date: 2021/9/17
 */
@Controller //这里必须使用@Controller，因为@RestController返回的是json格式，无法被thymeleaf解析
public class TestController {

    @RequestMapping("/test")
    public String test(Model model) {
        model.addAttribute("msg", "hello,springboot");
        return "test";
    }

    @RequestMapping("/test2")
    public String test2(Model model) {
        model.addAttribute("msg", "<h1>hello,springboot</h1>");
        return "test2";
    }

    @RequestMapping("/test3")
    public String test3(Model model) {
        model.addAttribute("users", Arrays.asList("keke","chimu"));
        return "test3";
    }

}
